package com.hsmw.api.controller.driver;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hsmw.api.service.HsmwVehicleRefuelingService;
import com.hsmw.common.base.*;
import com.htn.common.core.base.BusinessType;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.CommonConstants;
import com.hsmw.domain.HsmwReport;
import com.hsmw.domain.HsmwVehicleRefueling;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Date;

/**
 * <p>
 * 司机加油 前端控制器
 * </p>
 *
 * @author tjy
 * @since 2021-07-23
 */
@Api(tags = "司机加油")
@RestController
@RequestMapping("/hsmw/refueling")
public class HsmwVehicleRefuelingController extends BaseController<HsmwVehicleRefuelingService, HsmwVehicleRefueling> {



    @Autowired
    private HsmwVehicleRefuelingService hsmwVehicleRefuelingService;


    @Log(title = "司机加油新增", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "司机加油新增", notes = "司机加油新增", produces = "application/json")
    @PostMapping("vehicleRefuelingSave")
    public DataResponse vehicleRefuelingSave(@RequestBody HsmwVehicleRefueling hsmwVehicleRefueling){
        if(hsmwVehicleRefueling == null){
            return new DataResponse(CommonConstants.ResponseStatus.FAIL,"参数不可为空");
        }

        return new DataResponse(hsmwVehicleRefuelingService.vehicleRefuelingSave(hsmwVehicleRefueling));
    }



    @ApiOperation(value = "司机加油修改", notes = "司机加油修改", produces = "application/json")
    @PostMapping("updateVehicleRefueling")
    public DataResponse updateVehicleRefueling(@RequestBody HsmwVehicleRefueling hsmwVehicleRefueling){
        if(hsmwVehicleRefueling == null){
            return new DataResponse(CommonConstants.ResponseStatus.FAIL,"参数不可为空");
        }

        return new DataResponse(hsmwVehicleRefuelingService.updateVehicleRefueling(hsmwVehicleRefueling));
    }



    @ApiOperation(value = "根据司机id查询加油记录", notes = "根据司机id查询加油记录", produces = "application/json")
    @ApiImplicitParam(name = "id",value = "司机id",dataType = "String")
    @PostMapping("findVehicleRefuelingInfoByDriId")
    public DataResponse findVehicleRefuelingInfoByDriId(String id){

        return new DataResponse(hsmwVehicleRefuelingService.findVehicleRefuelingInfoByDriId(id));
    }



    @ApiOperation(value = "获取司机加油列表", notes = "获取司机加油列表", produces = "application/json")
    @PostMapping("/getHsmwVehicleRefuelingList")
    public DataResponse getHsmwVehicleRefuelingList(@RequestBody @Valid BasePage<HsmwVehicleRefueling> basePage) {
        IPage page = new Page(basePage.getPageNo(), basePage.getPageSize());
        HsmwVehicleRefueling hsmwVehicleRefueling = basePage.getRequestData();
        IPage<HsmwVehicleRefueling> data = hsmwVehicleRefuelingService.getHsmwVehicleRefuelingList(page, hsmwVehicleRefueling);
        return new DataResponse(data);
    }



}

